<?
//****Made by: Jeroen den Haan***Alias's: jeroen84 / Jer'ul****
include_once ("_data.php");

	 //print_r($_POST);

	 
	$name = $_POST['name'];
	$score = $_POST['score'];
	$password = $_POST['pass'];
	//echo $name;
	//echo $score;
	//echo $password;

if ($password==$add_pass) {
	

if ($u_user==1) {

	$sql3 = "SELECT name FROM $db_table ORDER BY name";
	$result3 = mysql_query($sql3);
	while($r = mysql_fetch_object($result3)) 
	{
		$tmp = "{$r->name}";
		if ($name==$tmp) {
			$n_exist=1;

		}
	}
	if ($n_exist==1) {
		$sql1 = "UPDATE $db_table SET score='$score' WHERE name=\"$name\"";
		$result1 = mysql_query($sql1);
	} else {
		$sql1 = "INSERT INTO $db_table (name,score) VALUES (\"$name\",\"$score\")";
		$result1 = mysql_query($sql1);
	}

} else {
$sql1 = "INSERT INTO $db_table (name,score) VALUES (\"$name\",\"$score\")";
$result1 = mysql_query($sql1);
}

$sql2 = "SELECT id FROM $db_table ORDER BY score DESC";
$result2 = mysql_query($sql2);

$num = 1;
while($r = mysql_fetch_object($result2))
{
$result = mysql_db_query($db_name,"SELECT * from $db_table WHERE id='{$r->id}'");
$resultArray = mysql_fetch_array($result);
$did = $resultArray["id"];
$name = $resultArray["name"];
$score = $resultArray["score"];
if ($num>$sec_size) {
	$sql3 = "DELETE FROM $db_table WHERE id='$did'";
	$result3 = mysql_query($sql3);
}
$num++;
}
}
//echo "added!";

mysql_close ($conn);
?>
<script type="text/javascript">
<!--
window.location = "http://dunk2.jcu.edu.au/~jc203335/cerealbox.com.au"
//-->
</script>